package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.customer.QueryServiceErrorFormBean;
import com.info.zhiduoduo.admin.model.formbean.customer.SaveServiceErrorFormBean;
import com.info.zhiduoduo.admin.model.formbean.customer.SolveServiceErrorFormBean;
import com.info.zhiduoduo.admin.model.formbean.customer.UpdateServiceErrorFormBean;
import com.info.zhiduoduo.admin.service.ServiceErrorService;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.customer.ServiceErrorDto;
import com.info.zhiduoduo.repository.entity.customer.ServiceError;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "客服事务异常记录")
@RestController
@RequestMapping("/serviceError")
public class ServiceErrorController {
    @Autowired
    private ServiceErrorService serviceErrorService;

    @ZddLog(name = "增加和服异常事务")
    @ApiOperation("增加客服异常事务")
    @PostMapping("/saveServiceError")
    public SmartResult saveServiceError(@RequestBody BaseSimpleFormBean<SaveServiceErrorFormBean> formBean) {
        return serviceErrorService.saveServiceError(formBean);
    }

    @ZddLog(type = ZddLogType.UPDATE,name = "修改客服异常事务",entities = @LogEntity(entity = ServiceError.class,parameters =
    @LogParameter(fields = "id",parameters = "formBean.reqdata.id")))
    @ApiOperation("修改客服异常事务")
    @PostMapping("/updateServiceError")
    public SmartResult updateServiceError(@RequestBody BaseSimpleFormBean<UpdateServiceErrorFormBean> formBean) {
        return serviceErrorService.updateServiceError(formBean);
    }

    @ZddLog(name = "解决客服异常事务")
    @ApiOperation("解决客服异常事务")
    @PostMapping("/solveServiceError")
    public SmartResult solveServiceError(@RequestBody BaseSimpleFormBean<SolveServiceErrorFormBean> formBean) {
        return serviceErrorService.solveServiceError(formBean);
    }



    @ApiOperation("查询客服异常事务")
    @PostMapping("/queryServiceError")
    public SmartResult<ServiceErrorDto> queryServiceError(@RequestBody BaseSimpleFormBean<QueryServiceErrorFormBean> formBean) {
        return serviceErrorService.queryServiceError(formBean);
    }



}
